home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap08 / dun8_9.txt < prev   
Encoding:
Text File  |  1997-12-18  |  707 b   |  30 lines

  1. <script language="JavaScript">
  2.  
  3. <!---//
  4.  
  5. //returns "2" for a JavaScript 1.0 compliant browser
  6.  
  7. //or "3" for a JavaScript 1.1 or higher browser
  8.  
  9. function whichVersion() {
  10.  
  11.    var myBrowser = navigator.userAgent;
  12.  
  13.    if(myBrowser.lastIndexOf("MSIE") != -1) return "2";
  14.  
  15.    if((myBrowser.lastIndexOf("4.0") != -1) ||
  16.  
  17.      (myBrowser.lastIndexOf("3.0") != -1)) {
  18.  
  19.      return "3";
  20.  
  21.      } else {
  22.  
  23.      return "2";
  24.  
  25.    }
  26.  
  27. }
  28.  
  29.  
  30.  
  31. function someFunction() {
  32.  
  33.    //wrap this function in a conditional whichVersion()
  34.  
  35.    if (whichVersion() == "3") {
  36.  
  37.  
  38.  
  39.    //JavaScript 1.1 specific code goes here....
  40.  
  41.  
  42.  
  43.    }
  44.  
  45.  
  46.  
  47.    //JavaScript 1.0 compatible code goes here....
  48.  
  49.  
  50.  
  51.  
  52.  
  53. }
  54.  
  55. //--->
  56.  
  57. </script>
  58.  
  59.